package jjn.acwing;

import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/8/4 09:27
 */
public class Acwing787 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int total = scanner.nextInt();
            int[] nums = new int[total];
            for (int i = 0; i < total; i++) {
                nums[i] = scanner.nextInt();
            }
            new Acwing787().mergesort(nums, 0, nums.length - 1);
            for (int num : nums) {
                System.out.print(num);
                System.out.print(" ");
            }
        }
    }
    
    void mergesort(int[] nums, int left, int right) {
        if (left >= right) {
            return;
        }
        int mid = (left + right) >> 1;
        mergesort(nums, left, mid);
        mergesort(nums, mid + 1, right);
        int k = 0, i = left, j = mid + 1;
        int[] temp = new int[right - left + 1];
        while (i <= mid && j <= right) {
            if (nums[i] <= nums[j]) {
                temp[k++] = nums[i++];
                continue;
            }
            temp[k++] = nums[j++];
        }
        while (i <= mid) {
            temp[k++] = nums[i++];
        }
        while (j <= right) {
            temp[k++] = nums[j++];
        }
        for (k = 0, i = left; i <= right; i++, k++) {
            nums[i] = temp[k];
        }
    }
}
